home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / exec / openlibrary.c < prev    next >
C/C++ Source or Header  |  1996-09-12  |  2KB  |  101 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: openlibrary.c,v 1.4 1996/08/13 13:56:05 digulla Exp $
  4.     $Log: openlibrary.c,v $
  5.     Revision 1.4  1996/08/13 13:56:05  digulla
  6.     Replaced __AROS_LA by __AROS_LHA
  7.     Replaced some __AROS_LH*I by __AROS_LH*
  8.     Sorted and added includes
  9.  
  10.     Revision 1.3  1996/08/01 17:41:15  digulla
  11.     Added standard header for all files
  12.  
  13.     Desc:
  14.     Lang: english
  15. */
  16. #include <exec/execbase.h>
  17. #include <exec/lists.h>
  18. #include <aros/libcall.h>
  19.  
  20. /*****************************************************************************
  21.  
  22.     NAME */
  23.     #include <exec/libraries.h>
  24.     #include <clib/exec_protos.h>
  25.  
  26.     __AROS_LH2(struct Library *, OpenLibrary,
  27.  
  28. /*  SYNOPSIS */
  29.     __AROS_LHA(UBYTE *, libName, A1),
  30.     __AROS_LHA(ULONG,   version, D0),
  31.  
  32. /*  LOCATION */
  33.     struct ExecBase *, SysBase, 92, Exec)
  34.  
  35. /*  FUNCTION
  36.     Opens a library given by name and revision. If the library
  37.     doesn't exist in memory it is tried to load it from disk.
  38.     It this fails too, NULL is returned.
  39.  
  40.     INPUTS
  41.     libName - Pointer to the library's name.
  42.     version - the library's version number.
  43.  
  44.     RESULT
  45.     Pointer to library structure or NULL.
  46.  
  47.     NOTES
  48.  
  49.     EXAMPLE
  50.  
  51.     BUGS
  52.  
  53.     SEE ALSO
  54.     CloseLibrary().
  55.  
  56.     INTERNALS
  57.  
  58.     HISTORY
  59.     21-10-95    digulla automatically created from
  60.                 include:clib/exec_protos.h
  61.  
  62. *****************************************************************************/
  63. {
  64.     __AROS_FUNC_INIT
  65.  
  66.     __AROS_BASE_EXT_DECL(struct ExecBase *,SysBase)
  67.     struct Library * library;
  68.  
  69.     /* Arbitrate for the library list */
  70.     Forbid();
  71.  
  72.     /* Look for the library in our list */
  73.     library = (struct Library *) FindName (&SysBase->LibList, libName);
  74.  
  75.     /* Something found ? */
  76.     if(library!=NULL)
  77.     {
  78.     /* Check version */
  79.     if(library->lib_Version>=version)
  80.     {
  81.         /* Call Open vector */
  82.         library=__AROS_LVO_CALL1(struct Library *,1,library,version,D0);
  83.     }else
  84.         library=NULL;
  85.     }
  86.     /*
  87.     else
  88.     {
  89.     Under normal circumstances you'd expect the library loading here -
  90.     but this is only exec which doesn't know anything about the
  91.     filesystem level. Therefore dos.library has to SetFunction() this vector
  92.     for the additional functionality.
  93.     }
  94.     */
  95.  
  96.     /* All done. */
  97.     Permit();
  98.     return library;
  99.     __AROS_FUNC_EXIT
  100. } /* OpenLibrary */
  101.